package com.dome.common.exception;

import com.dome.common.enumeration.DomeErrorCode;

public class DomeException extends RuntimeException {

    private static final long serialVersionUID = -5158450024786211077L;
    private DomeErrorCode errorCode;

    public DomeException() {
        this(DomeErrorCode.SYSTEM_ERROR);
    }

    public DomeException(String message) {
        super(message);
        this.errorCode = DomeErrorCode.SYSTEM_ERROR;
    }

    public DomeException(DomeErrorCode errorCode) {
        super(errorCode.getDesc());
        this.errorCode = errorCode;
    }

    public DomeException(DomeErrorCode errorCode, Object... errorMsg) {
        super(String.format(errorCode.getDesc(), errorMsg));
        this.errorCode = errorCode;
    }

    public DomeException(String message, DomeErrorCode errorCode) {
        super(message);
        this.errorCode = errorCode;
    }

    public DomeException(String message, Throwable cause, DomeErrorCode errorCode) {
        super(message, cause);
        this.errorCode = errorCode;
    }

    public DomeException(Throwable cause, DomeErrorCode errorCode) {
        super(cause);
        this.errorCode = errorCode;
    }

    public DomeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, DomeErrorCode errorCode) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.errorCode = errorCode;
    }

    public DomeException(String s, Exception e) {
        super(s, e);
    }

    public DomeException(String s, Throwable e) {
        super(s, e);
    }

    @Override
    public String toString() {
        return "CreditCrmException{" +
                "errorCode=" + errorCode +
                "} " + super.toString();
    }

    public DomeErrorCode getErrorCode() {
        return errorCode;
    }

}
